/*
 * @Description: 三维环绕
 */
import BaseCommand from "@/core/Frame/BaseClass/BaseCommand";

class RotatingCommand extends BaseCommand {
    viewer: any;
    globeControl: any;
    globe: any;
    timer:any;
    constructor(params: any) {
        super();
        this.viewer = params.viewer;
        this.globeControl = this.viewer.getGlobeControl();
        this.globe = this.viewer.getGlobe();
    };
    execute(option: any) {
        let that=this.globe;
        let thatoption=option;
        let Angle=that.getHeadingAngle();
        this.timer = setInterval(function() {
            that.setHeadingAngle(Angle); // 设置地图翻转（绕z轴旋转）角度
            that.refresh(false, false); // 刷新地图窗口
            Angle-=0.05;
        }, 30);
        let thatTimer=this.timer;
        document.addEventListener(
            'mousedown',
            function (e:any) {
                clearInterval(thatTimer);
                thatoption.checked =false;
            }
        );
    };
    release() {
        const { globeControl } = this;
        const { PIE } = window;
        globeControl.setGlobeTool(PIE.GlobeToolType.Pan);
    };
    isEnable() {
        return true;
    };
}

export default RotatingCommand;
